package com.threefivework.mymall.dao;

import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author yuanshi.fu
 * @description:
 * @date 2018/6/29 下午1:27
 */
public class BaseDAO {

    private static final Logger logger = LoggerFactory.getLogger(BaseDAO.class);

    private String namespaceName;

    public BaseDAO() {
    }

    public BaseDAO(String namespaceName) {
        this.namespaceName = namespaceName;
    }

    public String getStatementName(String id) throws Exception {
        if (StringUtils.isEmpty(namespaceName)) {
            logger.warn("[BaseDAO] getStatement namespaceName为空");
            throw new Exception("namespaceName为空");
        }

        if (StringUtils.isEmpty(id)) {
            logger.warn("[BaseDAO] getStatement id为空");
            throw new Exception("id为空");
        }
        StringBuffer statementSB = new StringBuffer(namespaceName);
        return statementSB.append(namespaceName).append(".").append(id).toString();
    }
}
